package per.turtle.common.mq.config;

import lombok.RequiredArgsConstructor;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import per.turtle.common.mq.constant.RabbitConstant;

/**
 * @author yuj
 */
@Configuration
@RequiredArgsConstructor
public class RabbitConfig {

    private final RabbitAdmin rabbitAdmin;

    @Bean
    public Queue queue() {
        Queue queue = new Queue(RabbitConstant.IP_ADDRESS_QUEUE, true);
        // 显式声明邮件队列
        rabbitAdmin.declareQueue(queue);
        return queue;
    }

}
